import request from '@/utils/request';
import { CORE_JAR_PREFIX } from '@/utils/constants';

export function fetchUnits({ h, p=0, t=0, startTime='', endTime='', price='[{"s":0,"e":-1,"c":1,"p":1}]'}) {
  return request('/hws/' + CORE_JAR_PREFIX + '/EnergySearch',
    { method: 'energyUnits', h, p, t, startTime, endTime, price },
    'POST'
  );
}

export function fetchSum({ h, p=0, startTime='', endTime='', price='[{"s":0,"e":-1,"c":1,"p":1}]'}) {
  return request('/hws/' + CORE_JAR_PREFIX + '/EnergySearch',
    { method: 'energySum', h, p, startTime, endTime, price },
    'POST'
  );
}

export function fetchSame({ h, p=0, startTime='', endTime='', price='[{"s":0,"e":-1,"c":1,"p":1}]'}) {
  return request('/hws/' + CORE_JAR_PREFIX + '/EnergySearch',
    { method: 'energySame', h, p, startTime, endTime, price },
    'POST'
  );
}

export function fetchProportionTrend({ h, p=0, t=0, startTime='', endTime='', price='[]'}) {
  return request('/hws/' + CORE_JAR_PREFIX + '/EnergySearch',
    { method: 'energyProportionTrend', h, p, t, startTime, endTime, price },
    'POST'
  );
}

